//
//  UIAlertController+Show.m
//  NoNeedle
//
//  Created by Ming Tian on 2017/3/3.
//  Copyright © 2017年 Ming Tian. All rights reserved.
//

#import "UIAlertController+Show.h"

@implementation UIAlertController (Show)

+ (void)showAlertToViewController:(UIViewController *)viewController withTitle:(NSString *)title message:(NSString *)message confirmHandler:(confirmHandler)confirmHandler {
    
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:@"确定" style:UIAlertActionStyleDefault handler:confirmHandler];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:@"取消" style:UIAlertActionStyleCancel handler:nil];
    [alertController addAction:confirmAction];
    [alertController addAction:cancelAction];
    [viewController presentViewController:alertController animated:YES completion:nil];
}

+ (void)showAlertToViewController:(UIViewController *)viewController withTitle:(NSString *)title message:(NSString *)message confirmTitle:(NSString *)confirmTitle cancelTitle:(NSString *)cancelTitle confirmHandler:(confirmHandler)confirmHandler cancelHandler:(cancelHandler)cancelHandler complete:(completeHandler)complete {
    UIAlertController *alertController = [UIAlertController alertControllerWithTitle:title message:message preferredStyle:UIAlertControllerStyleAlert];
    UIAlertAction *confirmAction = [UIAlertAction actionWithTitle:confirmTitle style:UIAlertActionStyleDefault handler:confirmHandler];
    UIAlertAction *cancelAction = [UIAlertAction actionWithTitle:cancelTitle style:UIAlertActionStyleCancel handler:cancelHandler];
    [alertController addAction:confirmAction];
    [alertController addAction:cancelAction];
    [viewController presentViewController:alertController animated:YES completion:complete];
}

@end
